<template>
  <div class="camIcons">
    <template v-for="d in devIcons">
      <div class="icon60x60 i60-1-9" :style="['top:' + d.pos.y + 'px;', 'left:' + d.pos.x + 'px;']" v-show="_showIcons">
        <div class="cam-line">
          <!-- <div v-if="d.dat.modelType === 327" @dblclick="hDbCam(d, $event)"> -->
          <div v-if="d.typeId === 72" @click="hDbCam(d, $event)">
            <div class="icon60x60 cam-top1 btn" :class="['icon_' + d.modelType]">
              <div :class="[d.modelType == 340 ? 'pdftext' : 'text']" :id="'ups-' + d.id"
                v-show="d.typeId === 72 ? true : false">
                <div class="hr">
                  &nbsp;&nbsp;
                  {{ d.code }}
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                </div>
                <!-- <div class="Tbox" :name="['name-' + d.dat.ID]" :txt="['none']">
								<div v-for="n in upsInfoMod" class="www">{{ n["key"] }}:
									<span style="color:#00F5FF ;">{{ n["val"] }}</span>
								</div>
						
							</div> -->
              </div>
            </div>
          </div>
          <!-- <div v-else class="labelMain" @dblclick="hDbCam(d, $event)">  :style="['transform: translateX(100px);filter: drop-shadow(-100px 0px 0px '+d.color+');']"-->
          <div v-else class="labelMain" @dblclick="hDbCam(d, $event)">
            <div class="icon60x60 cam-top btn" :class="['icon_' + d.modelType]">
              <div :class="[d.modelType == 3 ? 'pdftext' : 'text']" :id="'ups-' + d.id"
                v-show="d.typeId === 1 ? true : false">
                <div class="hr">
                  &nbsp;&nbsp;
                  {{ d.code }}
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                </div>
                <!-- <div class="Tbox" :name="['name-' + d.dat.ID]" :txt="['none']">
								<div v-for="n in upsInfoMod" class="www">{{ n["key"] }}:
									<span style="color:#00F5FF ;">{{ n["val"] }}</span>
								</div>

							</div> -->
              </div>
            </div>
          </div>
        </div>
      </div>
    </template>
    <!-- <div style="top: 271px; left: 888px; z-index: 101"> -->
    <el-monitor-land ref="childRf" :show-monitor="showMonitor" :monitor-form="monitorForm"></el-monitor-land>
    <!-- </div> -->
  </div>
</template>

<script setup>
import elMonitorLand from './el-monitor-land.vue'

import { computed, watch, ref, onUnmounted, onMounted, nextTick, toRefs } from 'vue'

import { useStore } from 'vuex'

// transform: translateX(100px);
// filter: drop-shadow(-100px 0px 0px red);
const store = useStore()

const { scene3d, devIcons, api, _showIcons, _camDat } = toRefs(store.state)

const showMonitor = ref(false)
const monitorForm = ref({})
const childRf = ref(null)
const roomLit = ref([
  {
    name: '大剧院配电室',
    label: 'dajuyuan',
    isclick: false
  },
  {
    name: '实训楼配电室',
    label: '3#2',
    isclick: false
  },
  {
    name: '食堂配电室',
    label: 'shitang',
    isclick: false
  },
  {
    name: '宿舍楼配电室',
    label: 'sushelou',
    isclick: false
  },
  {
    name: '体育馆配电室',
    label: 'tiyuguan',
    isclick: false
  },
  {
    name: '行政楼配电室',
    label: 'xingzhenglou',
    isclick: false
  }
])
const OnRelPos = (dps) => {
  let idCam = _devTypes.摄像头.typeId
  _devs.value = dps.filter((d) => d.typeId == idCam)
}

var _devTypes

const hShowTbox = (x, y) => {
  showTbox.value = true
  //tboxPos.value=`transform: translate(${x}px, ${y}px);`;
}
watch(_camDat, () => {
  hDbCam(_camDat.value)
})

let index_Cam = 1
const hDbCam = (d, e) => {
  console.log("标签点击");
  console.log(d);
  console.log(e);

  index_Cam += 1
  monitorForm.value = d
  showMonitor.value = true

  childRf.value.changemonitorForm(d, index_Cam)
  console.log(d)
  if (d.modelType == 340) {
    window.s3d.SetPDRoomHeatMap(false)
    window.s3d.SetCamToRoom({
      roomNumber: roomLit.value.find((t) => t.name == d.code)?.label,
      height: 10,
      distance: 20,
      speed: 5
    })
    setTimeout(() => {
      window.s3d.SetUpdateModPos()
    }, 1500)
  } else {
    var tempDat = new Object()
    d['SXTJSON'] = d.code
    tempDat['dat'] = d
    tempDat['code'] = d.code
    __dataBack(tempDat)
  }
}

const hDbJqJd = (d) => {
  console.log('景区景点。', d)
}
const hCloseVideo = () => {
  _showVideo.value = false
  wvideo.value.style = ''
  hFree(wvideo.value.id)
  _vsrc.value = ''
}
const hRefPage = () => {
  console.log("标签数据：", devIcons)
  _devTypes = scene.deviceType
}
onMounted(() =>
  nextTick(() => {
    hRefPage()
    // GetFire()
  })
)
</script>

<style scoped lang="scss">
.camIcons {
  //   position: relative;
}

.labelMain {
  width: 60px;
  height: 60px;
  overflow: hidden;
  display: block;
  position: relative;
  pointer-events: all;
  cursor: pointer;
  margin-top: 50px;
  margin-left: -29px;
}

.labelMain:hover {
  position: absolute;
  transform: scale(1.2);
  pointer-events: all !important;
}

.camIcons>div {
  position: absolute;
  transform: translate(-50%, -50%) scale(0.8);
  pointer-events: all !important;
}

.camIcons>div:hover {
  z-index: 1000000;
}

.cam-line {
  position: absolute;
  height: 100px;
  width: 2px;
  /**background-color: red;**/
  bottom: 50%;
  left: 50%;

  .text {
    display: block;
    min-width: 100px;
    width: fit-content;
    height: 80px !important;
    background-image: url(/imgs/unityImg/text.png);
    background-size: 100%;
    margin: -15px calc(100% - 10px);
    font-family: '';
    white-space: nowrap;
    position: relative;
    z-index: -1;
    font-weight: bolder;
    line-height: 75px;
    color: white;
    text-indent: 1rem;
    letter-spacing: 3px;
  }

  .cam-top {
    position: absolute;
    // top: 50px;
    // left: -29px;

    .carp {}

    .wc {}
  }

  .pdftext {
    display: block;
    min-width: 100px;
    width: fit-content;
    height: 80px !important;
    background-image: url(/imgs/unityImg/pdftext.png);
    background-size: 80%;
    margin: -12px calc(100% - 29px);
    font-family: '';
    white-space: nowrap;
    position: relative;
    z-index: -1;
    font-weight: bolder;
    line-height: 75px;
    color: white;
    text-indent: 1rem;
    letter-spacing: 2px;
  }

  .cam-top1 {
    position: absolute;
    top: 50px;
    left: -29px;

    .text {
      display: block;
      min-width: 100px;
      width: fit-content;
      height: 80px !important;
      background-image: url(/imgs/unityImg/text.png);
      background-size: 100%;
      margin: -10px calc(100% - 19px);
      font-family: '';
      white-space: nowrap;
      position: relative;
      z-index: -1;
      font-weight: bolder;
      line-height: 75px;
      color: white;
      text-indent: 1rem;
    }

    .carp {}

    .wc {}
  }
}

.Tbox {
  background-image: url(/imgs/wznt/弹窗.png);
  background-size: 100% 100%;
  top: 0;
  left: 0;
  position: absolute;
  width: 300px;
  height: 200px;
  overflow: scroll;

  .closeBtn {
    content: 'X';
    position: absolute;
    width: 20px;
    height: 20px;
    cursor: pointer;
    display: block;
    line-height: 20px;
    text-indent: 0;
    right: 0;
    top: 10px;
  }

  .closeBtn:hover {
    color: red;
  }
}

.www {
  display: flex;
  font-size: 5px;
  // position: relative;
  height: 20px;
}

.btn {
  width: 60px;
  height: 60px;
  background-size: 60px 60px;
  background-position: 0 0;
}

// 监控
.icam {
  .cam-line {

    // background-color: #ECC300;
    >div {
      background-image: url(/imgs/wznt/cam.png);
      background-size: 60px 55px;
      background-position: 0 0;
    }
  }
}

// 摄像头 typeId=1  modelType =1
.icon_3 {
  background-image: url(/imgs/unityImg/44.png);
}

// 水表 typeId =12 modelType =29
.icon_29 {
  background-image: url(/imgs/nbys/33.png);
}

// 电表 typeId = 12 modelType =30
.icon_30 {
  background-image: url(/imgs/nbys/11.png);
}

// 电表 typeId = 12 modelType =30
.icon_220 {
  background-image: url(/imgs/nbys/55.png);
}

// 楼宇标签 typeId =72  modelType =327
.icon_327 {
  background-image: url(/imgs/nbys/2.png);
}

// 楼宇标签 typeId =72  modelType =340
.icon_340 {
  background-image: url(/imgs/nbys/pdf.png);
}
</style>
